/*
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#include "./position.h"
#include <stdio.h>

Position::Position()
{
  lat = 0;
  lon = 0;
}

Position::Position(sint32 lt, sint32 ln)
{
  lat = SEMI2DEG(lt);
  lon = SEMI2DEG(ln);
}

Position::Position(double lt, double ln)
{
  lat = lt;
  lon = ln;
}

Position::Position(position_type *p)
{
  lat = SEMI2DEG(p->lat);
  lon = SEMI2DEG(p->lon);
}

Position::Position(position_type p)
{
  lat = SEMI2DEG(p.lat);
  lon = SEMI2DEG(p.lon);
}

QString Position::toString()
{
  QString string("");
  string += "[ POSITION";
  string += " lat: ";
  string += QVariant(lat).toString();
  string += " lon: ";
  string += QVariant(lon).toString();
  string += " ]";
  return string;
}

bool Position::isValid()
{
  if (lat > 179 && lon > 179)
    return false;
  return true;
}

double Position::getLat()
{
  return lat;
}

double Position::getLon()
{
  return lon;
}

void Position::setLat(double l)
{
  lat = l;
}

void Position::setLon(double l)
{
  lon = l;
}

bool Position::compareTo(Position p)
{
  return (lat == p.lat) && (lon == p.lon);
}